/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Jirka
 */
@Entity
@Table(name = "league")
@NamedQueries({@NamedQuery(name = "League.findAll", query = "SELECT l FROM League l"), @NamedQuery(name = "League.findByLeagueId", query = "SELECT l FROM League l WHERE l.leagueId = :leagueId"), @NamedQuery(name = "League.findByName", query = "SELECT l FROM League l WHERE l.name = :name"), @NamedQuery(name = "League.findByCountry", query = "SELECT l FROM League l WHERE l.country = :country")})
public class League implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "league_id")
    private Integer leagueId;
    @Column(name = "name")
    private String name;
    @Column(name = "country")
    private String country;
    @ManyToMany(mappedBy = "leagueCollection")
    private Collection<Club> clubCollection;
    @OneToMany(mappedBy = "league")
    private Collection<Game> gameCollection;

    public League() {
        this.clubCollection = new ArrayList<Club>();
        this.gameCollection = new ArrayList<Game>();
    }

    public League(Integer leagueId) {
        this.leagueId = leagueId;
    }

    public Integer getLeagueId() {
        return leagueId;
    }

    public void setLeagueId(Integer leagueId) {
        this.leagueId = leagueId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public Collection<Club> getClubCollection() {
        return clubCollection;
    }

    public void setClubCollection(Collection<Club> clubCollection) {
        this.clubCollection = clubCollection;
    }

    public Collection<Game> getGameCollection() {
        return gameCollection;
    }

    public void setGameCollection(Collection<Game> gameCollection) {
        this.gameCollection = gameCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (leagueId != null ? leagueId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof League)) {
            return false;
        }
        League other = (League) object;
        if ((this.leagueId == null && other.leagueId != null) || (this.leagueId != null && !this.leagueId.equals(other.leagueId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.League[leagueId=" + leagueId + "]";
    }

}
